#include"processBar.h"
#include<unistd.h>

/*void bar()
{
	
	int cnt=10;
	while(cnt>=0)
	{
		printf("%-2d\r",cnt);
		cnt--;
		fflush(stdout);
		sleep(1);
	}
	printf("\n");
}*/

typedef void (*call_back)(int);//函数指针
void Download(call_back cb)
{
	int total=1000;
	int cur=0;
	while(cur<=total)
	{
		usleep(50000);//设置总的下载时间
		int rate=cur*100/total;//更新进度
		cb(rate);//通过回调函数打印进度
		cur+=10;
	}
	printf("\n");
}
int main()
{
	printf("Download1\n");
	Download(processbar);
	initbar();
	printf("Download2\n");
	Download(processbar);
	initbar();
	printf("Download3\n");
	Download(processbar);
	initbar();
	return 0;
}
